﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Tasks;
using System.ComponentModel;
using Common.Utilities;
using Common.Library;

namespace CommonControls
{
    public partial class AboutUs : UserControl
    {
        public AboutUs()
        {
            InitializeComponent();
            List<AboutUsProperties> menuItems = MenuHelper.GetAboutUsMenuItems();
            if (!AppResources.ShowUpgradePage)
            {
                menuItems.RemoveAt(1);
            }
            lbxAboutUs.ItemsSource = menuItems;
        }

        private void lbxAboutUs_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (lbxAboutUs.SelectedIndex == -1)
                return;

            string SelIndex = (lbxAboutUs.SelectedItem as AboutUsProperties).Id;
            switch (SelIndex)
            {
                case "1":
                    //rate this app
                    UtilitiesManager.ShowMarketplaceAppReviewTask();
                    break;
                case "2":
                    //upgrade page
                    PageHelper.NavigateTo(UtilitiesResources.UpgradePage);
                    break;
                case "3":
                    //related apps
                    UtilitiesManager.LaunchMarketplaceSearchTask();
                    break;
                case "4":
                    //share with friends
                    UtilitiesManager.ShareWithFriendsComposeEmailTask();
                    break;
                case "5":
                    //Feedback
                    PageHelper.NavigateTo(UtilitiesResources.ContactUsPage);
                    break;
            }
            lbxAboutUs.SelectedIndex = -1;
        }
    }
}
